//---------------------------------------------------------------------------

#ifndef CEditEuroH
#define CEditEuroH
//---------------------------------------------------------------------------
#include <SysUtils.hpp>
#include <Controls.hpp>
#include <Classes.hpp>
#include <Forms.hpp>
#include <ExtCtrls.hpp>
#include <Buttons.hpp>
#include "CtrlStd.h"
#include "Cedit.h"
#include "CEditNum.h"
#include "Messages.h"

//---------------------------------------------------------------------------
enum TypeMonnaieEdit { edEuro, edFranc };

//---------------------------------------------------------------------------

class CEditPrinc : public CEditNum
{
    // Variables de stockage
private:
    typedef   CEditNum inherited;

    enum TypeMonnaieEdit    m_TypeMonnaie;

    double __fastcall Conv(double dVal, bool bFrancs);

protected:
    // Déclaration des messages
    void __fastcall WMChar(Messages::TWMChar& Msg);

    // Déroutement des messages
    BEGIN_MESSAGE_MAP
        MESSAGE_HANDLER( WM_CHAR, TWMChar, WMChar)
    END_MESSAGE_MAP( inherited)

public:
    __fastcall CEditPrinc(TComponent* Owner);
    __property enum TypeMonnaieEdit TypeMonnaie = { read=m_TypeMonnaie, write=m_TypeMonnaie, default = edEuro};

__published:
    __property OnChange;
    __property OnKeyDown;
    __property OnKeyUp;
};

//---------------------------------------------------------------------------
class PACKAGE_CTRLSTD CEditEuro : public TCustomPanel
{
private:
    TLabel          *lLibelle; //Libéllé du composant
    CEditPrinc      *EditPrinc; //Saisie du montant en euro
    TSpeedButton    *BouttonAff; //Bouton pour afficher la deuxieme fenetre
    TForm           *FormPopUp; //Forme surgissante pour afficher et saisir les francs
    TPanel          *PanelAff; //Panel pour afficher en style combobox
    TLabel          *lAffFranc; //Affichage du montant en francs
    TPanel          *PanelBas; //Panel pour afficher le bas de la form
    CEditNum        *EditFranc; //Saisie du montant en francs
    TLabel          *lAffSymboleFr; //Affichage du symbole des francs a cote de la saisie
    TShape          *sRectTour; //Objet pour dessiner un rectangle autour de FormPopUp

    bool                m_bVisible;
    bool                m_bEnabled;
    bool                m_bTabStop;
//    bool                m_bVisuEuro;
    bool                m_bVisuBouton;
    bool                m_bParentColor;
    bool                m_bReadOnly;
    int                 m_nSizeEsp;
    TColor              m_FColorNeg;
    TColor              m_FColor;
    double              m_FMax;
    double              m_FMin;
    double              m_ValNS;
    AnsiString          m_asMask;
//    AnsiString          m_asText;
    bool                bFirstAff;
    int                 nEpaisseur;
    enum TypeVal        m_FTypeVal;
    AnsiString          m_aLibelle;

    void __fastcall BouttonAffClick( TObject *pSender);
    void __fastcall FormPopUpOnDeactivate( TObject *pSender);
    void __fastcall EditFrancKeyDown(TObject *Sender, WORD &Key, TShiftState Shift);
    void __fastcall EditPrincKeyDown(TObject *Sender, WORD &Key, TShiftState Shift);
    void __fastcall EditPrincEnter(TObject *Sender);
    void __fastcall EditPrincExit(TObject *Sender);

    AnsiString __fastcall SuppSeparMillier( AnsiString asText );
    AnsiString __fastcall AddSeparMillier( AnsiString asText);
    double __fastcall ConvFrToEu (double dVal, bool bFrancs);
    TColor __fastcall ChangeCouleur ( void );

    //Fondtion pas creer ou détruire les objets utilisés
    void __fastcall newPopUp(void);
    void __fastcall detruitPopUp(void);
    void __fastcall newBouttonAff(void);
    void __fastcall detruitBouttonAff(void);

    void __fastcall SetVisible( bool bValue);
    void __fastcall SetEnabled( bool bValue);
    void __fastcall SetTabStop( bool bValue);
    void __fastcall SetNSActive(bool bNSActive);
    void __fastcall SetStateNS(bool bStateNS){};
    void __fastcall SetVisuBouton( bool bVisu);
    void __fastcall SetParentColor( bool bParentColor);
    void __fastcall SetReadOnly( bool bReadOnly );
    void __fastcall SetFont ( TFont *pFont);
    void __fastcall SetLibelle( AnsiString aLibelle);
    void __fastcall SetLibelleFont( TFont *pFont);
    void __fastcall SetSizeEspace( int nValue);
    void __fastcall SetColorNeg(TColor cCouleur );
    void __fastcall SetColor(TColor cCouleur );
    void __fastcall SetMax(double dMax);
    void __fastcall SetMin(double dMin);
//    void __fastcall SetText(AnsiString asTextOrigin);
    void __fastcall SetValue(double Value);
	void __fastcall SetMaxLength(signed int iMaxLength);
    void __fastcall SetMask( AnsiString aMask);
    void __fastcall SetValNS( double Value ) { } ;
    void __fastcall SetTypeVal( enum TypeVal eTypeValeur );
    void __fastcall SetTypeMonnaie( enum TypeMonnaieEdit eTypeMonnaie );

    enum TypeMonnaieEdit    __fastcall GetTypeMonnaie(void);
    double __fastcall GetValue(void);
    double __fastcall GetValNS();
    TFont *__fastcall GetFont(void);
    TFont *__fastcall GetLibelleFont(void);
    AnsiString __fastcall GetLibelle(void);
    AnsiString __fastcall GetMask(void);
    bool __fastcall GetStateNS(void);
    bool __fastcall GetNSActive(void);
    bool __fastcall GetTabStop(void);
	int  __fastcall GetMaxLength(void);

    TNotifyEvent    FOnShowPopUp;
    TNotifyEvent    FOnHidePopUp;
    TNotifyEvent    FOnChange;
    TKeyEvent       FOnKeyDown;
    TKeyEvent       FOnKeyUp;

protected:
    void __fastcall WMWindowPosChanged( TWMWindowPosChanged &Msg);
    void __fastcall WMSetFocus( TWMSetFocus &Msg);
    BEGIN_MESSAGE_MAP
        MESSAGE_HANDLER( WM_WINDOWPOSCHANGED, TWMWindowPosChanged, WMWindowPosChanged)
        MESSAGE_HANDLER( WM_SETFOCUS, TWMSetFocus, WMSetFocus)
    END_MESSAGE_MAP( TCustomPanel)

    void __fastcall ShowPopUp( void );
    void __fastcall HidePopUp( void );
    void __fastcall OnChangeEdit( TObject *Sender );
    void __fastcall OnKeyDownEdit( TObject *Sender, Word &Key, TShiftState Shift );
    void __fastcall OnKeyUpEdit( TObject *Sender, Word &Key, TShiftState Shift );

public:

    __fastcall CEditEuro(TComponent* Owner);

    //Methode
    virtual void __fastcall Clear(void);

__published:

    __property enum TypeVal     TypeValeur  = { read=m_FTypeVal, write=SetTypeVal};
    __property double Valeur        = { read=GetValue, write=SetValue};
    __property double ValeurNS      = { read=GetValNS, write=SetValNS};
//    __property AnsiString Text      = { read=m_asText, write=SetText};
    __property double Min           = { read=m_FMin, write=SetMin, stored  = false};
    __property double Max           = { read=m_FMax, write=SetMax, stored = false};
    __property int SizeEspace       = { read=m_nSizeEsp , write=SetSizeEspace , default=10 };
    __property signed int MaxLength = { read=GetMaxLength, write=SetMaxLength};
    __property bool TabStop         = { read=GetTabStop , write=SetTabStop , default=true };
    __property bool Visible         = { read=m_bVisible , write=SetVisible , default=true};
    __property bool Enabled         = { read=m_bEnabled , write=SetEnabled , default=true};
    __property bool NSActive        = { read=GetNSActive, write=SetNSActive , default=false };
	__property bool StateNS         = { read=GetStateNS, write=SetStateNS};
//	__property bool VisuEuro        = { read=m_bVisuEuro, write=m_bVisuEuro , default=false};
    __property bool VisuBouton      = { read=m_bVisuBouton, write=SetVisuBouton , default=true};
    __property bool ParentColor     = { read=m_bParentColor, write=SetParentColor};
    __property bool ReadOnly        = { read = m_bReadOnly, write = SetReadOnly, default = false };
    __property enum TypeMonnaieEdit TypeMonnaie = { read=GetTypeMonnaie, write=SetTypeMonnaie, default = edEuro};
    __property AnsiString Libelle   = { read = GetLibelle , write=SetLibelle };
    __property AnsiString Mask      = { read=m_asMask, write=SetMask};
    __property TFont *Font          = { read=GetFont, write=SetFont};
    __property TFont *LibelleFont   = { read=GetLibelleFont , write=SetLibelleFont };
    __property TColor ColorNeg      = { read=m_FColorNeg, write=SetColorNeg};
    __property TColor Color         = { read=m_FColor, write=SetColor};
    __property BorderStyle = {default = bsSingle};
    __property ShowHint;
    __property TabOrder;
    __property ParentShowHint;
    __property ParentFont;

    __property TNotifyEvent OnShowPopUp = {read=FOnShowPopUp, write=FOnShowPopUp};
    __property TNotifyEvent OnHidePopUp = {read=FOnHidePopUp, write=FOnHidePopUp};
    __property TNotifyEvent OnChange    = {read=FOnChange, write=FOnChange};
    __property TKeyEvent    OnKeyDown   = {read=FOnKeyDown, write=FOnKeyDown};
    __property TKeyEvent    OnKeyUp     = {read=FOnKeyUp, write=FOnKeyUp};
    __property OnMouseMove;
    __property OnEnter;
    __property OnExit;
};
//---------------------------------------------------------------------------
#endif
